<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets" 
	xmlns:p="http://primefaces.org/ui">

	<h:form id="formAthleteData" prependId="false" >
		<script type="text/javascript" src="#{request.contextPath}/css/script/script.js"/>
		<h:panelGrid style="width:90%" cellpadding="2"  columns="2"  columnClasses="top-align,top-align">  
			<h:column>
				<h:panelGrid  columns="2"   columnClasses="top-align,top-align"   >   
					<h:column >
						<h:panelGrid columns="2" cellpadding="2" >
						
				            <h:outputLabel value="#{msgs.Email} :" for="athleteEmail" />
				            <p:inputText id="athleteEmail" value="#{athleteBean.athlete.user.email}" maxlength ="50" size="50" required="false" requiredMessage="#{msgs.EmailObligatory}"/>
			
			
							<h:outputLabel value="#{msgs.Password} :"	for="athletePassword" />
							<p:password id="athletePassword" autocomplete="off"	redisplay="true"
								value="#{ athleteBean.athlete.user.password}" maxlength="15"	size="15" required="true" requiredMessage="#{msgs.PasswordObligatory}"/>
				
				            <h:outputLabel value="#{msgs.Name} :" for="athleteName"  />
				            <p:inputText id="athleteName"    value="#{athleteBean.athlete.firstName}" maxlength ="20" size="20" required="true"  requiredMessage="#{msgs.AtlhleteNameObligatory}"/>
				
				            <h:outputLabel value="#{msgs.Surname} :" for="athleteSurName"  />
				            <p:inputText id="athleteSurName"    value="#{athleteBean.athlete.lastName}" maxlength ="30" size="30"	/>


				            <h:outputLabel value="#{msgs.Phone} :" for="athletePhone" styleClass="sp_celphones" />
				            <p:inputText id="athletePhone" 	value="#{athleteBean.athlete.user.phone}" maxlength ="22" size="22"  styleClass="sp_celphones"  />
			
				            <h:outputLabel value="#{msgs.CPF} :" for="athleteCpf" />
				            <p:inputText id="athleteCpf" 	value="#{athleteBean.athlete.cpf}" maxlength ="22" size="22" required="false" styleClass="cpf"  requiredMessage="#{msgs.UserCpfObligatory}"   />
			
				            <h:outputLabel value="#{msgs.BirthdayDate} :" for="athleteBirthday" />
							<p:calendar		id="athleteBirthday"	value="#{athleteBean.athlete.birthday}"	navigator="true" yearRange="c-100:c0"
								locale="pt"		timeZone="Brazil/East" selectOtherMonths="true" readOnlyInputText="true"  />
			
				
			    	        <h:outputLabel value="#{msgs.State} :" for="academyState" />
				            <p:inputText id="academyState" value="#{athleteBean.athlete.state}" maxlength ="30" size="30" />
		
			    	        <h:outputLabel value="#{msgs.City} :" for="academyCity" />
				            <p:inputText id="academyCity" value="#{athleteBean.athlete.state}" maxlength ="30" size="30" />
				
			    	        <h:outputLabel value="#{msgs.Adrress} :" for="academyAddress" />
				            <p:inputText id="academyAddress" value="#{athleteBean.athlete.address}" maxlength ="50" size="50" />
					
			    	        <h:outputLabel value="#{msgs.CEP} :" for="academyPostalCode" />
				            <p:inputText id="academyPostalCode" value="#{athleteBean.athlete.postalCode}" maxlength ="12" size="12"/>
			
				   	        <h:outputLabel value="#{msgs.MaritalStatus} :" for="athleteMarried" />
				            <p:selectOneMenu id="athleteMarried" value="#{athleteBean.athlete.married}" >
				                <f:selectItem itemLabel="#{msgs.Married}"  	 	itemValue="true"   />
				                <f:selectItem itemLabel="#{msgs.Single}"		itemValue="false" />
				            </p:selectOneMenu>
				
			   	        	<h:outputLabel value="#{msgs.Gender} :" for="athleteMale" />
				            <p:selectOneMenu id="athleteMale" value="#{athleteBean.athlete.male}" >
				                <f:selectItem itemLabel="#{msgs.Male}"  	itemValue="true"   />
				                <f:selectItem itemLabel="#{msgs.Female}"	itemValue="false" />
				            </p:selectOneMenu>
			
			   	        	<h:outputLabel value="#{msgs.RecoveryFactor} :" for="athleteRecovery" />
				            <p:selectOneMenu id="athleteRecovery" value="#{athleteBean.athlete.recoveryFactor}" >
				                <f:selectItem itemLabel="#{msgs.Slow}" 	 	itemValue="1" />
				                <f:selectItem itemLabel="#{msgs.Normal}"	itemValue="2" />
				                <f:selectItem itemLabel="#{msgs.Fast}"		itemValue="3" />
				            </p:selectOneMenu>


				            <h:outputText value="#{msgs.Status} :" rendered="#{p:ifAnyGranted(' ROLE_ACADEMY, ROLE_PERSONAL, ROLE_TEACHER')}" />
				            <p:selectOneRadio value="#{athleteBean.athlete.user.active}" rendered="#{p:ifAnyGranted(' ROLE_ACADEMY, ROLE_PERSONAL, ROLE_TEACHER')}" >
				                <f:selectItem itemLabel="#{msgs.Active}"  	itemValue="true"    />
				                <f:selectItem itemLabel="#{msgs.Inactive}"	itemValue="false" />
				            </p:selectOneRadio>
			
							<h:outputLabel 	value="#{msgs.CreatedAt} :"		for="athleteCreatedAt" rendered="#{athleteBean.athlete.id != null}"  />
							<p:inputText  	id="athleteCreatedAt" 	value="#{athleteBean.athlete.user.createdAt}" disabled="true" rendered="#{athleteBean.athlete.id != null}"   >
								<f:convertDateTime locale="pt" dateStyle="long" pattern="dd/MM/yyyy HH:mm" />
							</p:inputText>
			
							<h:outputLabel 	value="#{msgs.ChangedAt} :"		for="athleteChangedAt" rendered="#{athleteBean.athlete.id != null}"  />
							<p:inputText  	id="athleteChangedAt" 	value="#{athleteBean.athlete.user.lastChange}" disabled="true" rendered="#{athleteBean.athlete.id != null}"  >
								<f:convertDateTime locale="pt" dateStyle="long" pattern="dd/MM/yyyy HH:mm" />
							</p:inputText>
			
							<h:outputLabel 	value="#{msgs.ExpireOn} :"		for="athleteExpireOn" rendered="#{p:ifAnyGranted('ROLE_ACADEMY, ROLE_PERSONAL, ROLE_TEACHER')}" />
							<p:calendar		id="athleteExpireOn"	value="#{athleteBean.athlete.user.expireOn}" readonlyInput="true"	navigator="true" yearRange="c-10:c+10"
								locale="pt"		timeZone="Brazil/East" selectOtherMonths="true" readOnlyInputText="true" required="true" requiredMessage="#{msgs.ExpireOnObligatory}" 
								rendered="#{p:ifAnyGranted('ROLE_ACADEMY, ROLE_PERSONAL, ROLE_TEACHER')}" />
			
						</h:panelGrid>
					</h:column>
					<h:column>
						<p:commandLink id="photoAthlete" oncomplete="wdlgupload.show();" process="@this"  >
							<p:graphicImage title="#{msgs.Photo} 120px x 100px"  cache="false" 	
								url="#{athleteBean.athlete.photo.folder}#{athleteBean.athlete.photo.location}" height="120px" width="100px" style="border:1px solid;"/>
						</p:commandLink>
					</h:column>
				</h:panelGrid>	
			</h:column>
			<h:column>
				<p:dataTable id="modalityTable" value="#{athleteBean.athlete.schedules}" var="schedule" paginator="true" sortBy="name" sortOrder="descending"
					  style="width:450px;margin-left:50px" paginatorAlwaysVisible="false"  paginatorPosition="bottom" rows="8" emptyMessage="#{msgs.NoResults}">
					<p:columnGroup type="header" >  
						<p:row>
							<p:column colspan="5" style="text-align:center;">
								<f:facet name="header">
									<h:outputText value="#{msgs.AthleteModalitys}" />
								</f:facet>
							</p:column>
						</p:row>
						<p:row>
							<p:column colspan="1"  styleClass="ui-table-button-row">
								<f:facet name="header">
									<p:commandButton type="button" title="#{msgs.Add}" onclick="wfindModality.show();" update=":findModality" icon="ui-icon-plus" styleClass="ui-table-button"/>
								</f:facet>
							</p:column>
							<p:column	colspan="2">
								<f:facet name="header">
									<h:outputText value="#{msgs.Name}"/>
								</f:facet>
							</p:column>
							<p:column	colspan="1" >
								<f:facet name="header">
									<h:outputText id="collvl" value="#{msgs.FitnessLevel}"/>
									<p:overlayPanel for="collvl" showEvent="mouseover" hideEvent="mouseout" >
										<p>
											<h:outputText value="#{msgs.Sedentary}: " style="font-weight:bold" />
											<h:outputText value="#{msgs.SedentaryDescription}"/>
										</p>
										<p>
											<h:outputText value="#{msgs.Beginner}: " style="font-weight:bold" />
											<h:outputText value="#{msgs.BeginnerDescription}"/>
										</p>
										<p>
											<h:outputText value="#{msgs.Moderately} #{msgs.Trained}: " style="font-weight:bold" />
											<h:outputText value="#{msgs.ModeratelyTrainedDescription}"/>
										</p>
										<p>
											<h:outputText value="#{msgs.Trained}: " style="font-weight:bold" />
											<h:outputText value="#{msgs.TrainedDescription}"/>
										</p>
										<p>
											<h:outputText value="#{msgs.Highly} #{msgs.Trained}: " style="font-weight:bold" />
											<h:outputText value="#{msgs.HighlyTrainedDescription}"/>
										</p>
									</p:overlayPanel>

								</f:facet>
							</p:column>
							<p:column	colspan="1" >
								<f:facet name="header">
									<h:outputText value="#{msgs.CreatedAt}"/>
								</f:facet>
							</p:column>
						</p:row>	
					</p:columnGroup>
					<p:column colspan="2" headerText="#{msgs.Name}" style="max-height:15px !important;padding-top:0px !important;padding-bottom:0px !important" >
						<h:outputText value="#{schedule.modality.name}" />
					</p:column>
					<p:column colspan="1" styleClass="ui-table-button-row" >
						<p:commandButton title="#{msgs.Delete}" process="@this" onclick="wconfExcMod.show();"  update="modalityTable,:tabUser:formAthleteAvailability:tblAvailability" icon="ui-icon-trash" styleClass="ui-table-button" >
							<f:setPropertyActionListener target="#{athleteBean.selSchedule}" value="#{schedule}"/>
						</p:commandButton>
					</p:column>		
					<p:column colspan="1" style="max-height:15px !important;padding-top:2px !important;padding-bottom:0px !important" >
						<p:selectOneMenu  value="#{schedule.level}" styleClass="ui-selector-on-table" >
							<f:selectItem itemLabel="#{msgs.Sedentary}" 					itemValue="1"	/>
							<f:selectItem itemLabel="#{msgs.Beginner}" 						itemValue="2"	/>
							<f:selectItem itemLabel="#{msgs.Moderately} #{msgs.Trained}"	itemValue="3"	/>
							<f:selectItem itemLabel="#{msgs.Trained}"			 			itemValue="4"	/>
							<f:selectItem itemLabel="#{msgs.Highly}"						itemValue="5"	/>
						</p:selectOneMenu>

					</p:column>		
					<p:column colspan="2" headerText="#{msgs.CreatedAt}" style="max-height:15px !important;padding-top:0px !important;padding-bottom:0px !important">
						<h:outputText value="#{schedule.beginDate}">
							<f:convertDateTime locale="pt" dateStyle="long" pattern="dd/MM/yyyy HH:mm" />
						</h:outputText>
					</p:column>		
				</p:dataTable>						
			</h:column>
		</h:panelGrid>	
		<div align="left"   >
			<p:commandButton  value="#{msgs.Save}"		action="#{athleteBean.saveAthlete}"		
				ajax="true"	update=":growl,:content,:listAthleteForm"		icon="ui-icon-disk"	rendered="#{athleteBean.athlete.id != null}" />
			<p:commandButton  value="#{msgs.Create}"	action="#{athleteBean.createAthlete}"	
				ajax="true"	update=":growl,:content,:listAthleteForm"		icon="ui-icon-document"	rendered="#{athleteBean.athlete.id == null}" />
			<p:spacer width="50px"/>	
			<p:commandButton  value="#{msgs.Cancel}"	action="#{athleteBean.cancelChange}"	icon="ui-icon-cancel"/>
		</div>
	</h:form>
</html>